package com.woniu.swagger.controller;

import com.woniu.swagger.common.Result;
import com.woniu.swagger.model.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

@RestController
@Api(tags = "用户相关接口", description = "提供用户相关的 Rest API")
public class UserController {
    //用户相关功能

    //___________________________________________________________________________________________________
    @ApiOperation(value ="用户登录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "user", value = "用户账号密码", dataType = "User"),
            @ApiImplicitParam(name = "user_key", value = "验证码", dataType = "String")
    })
    @PostMapping("user/login")
    public Result auditCompany(User user, String userKey){

        return Result.success(user);
    }

    @ApiOperation(value ="用户注册")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userName", value = "用户名", dataType = "String"),
            @ApiImplicitParam(name = "userPassword", value = "用户密码", dataType = "String"),
            @ApiImplicitParam(name = "user_key", value = "验证码", dataType = "String")
    })
    @PostMapping("user/register")
    public Result checkMaterial(String userName,String userPassword,String userKey){
        return Result.success("注册成功");
    }


    @ApiOperation(value ="添加出行人")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "travelerName", value = "出行人姓名", dataType = "String"),
            @ApiImplicitParam(name = "travelerType", value = "出行人类型", dataType = "String"),
            @ApiImplicitParam(name = "travelerTel", value = "出行人", dataType = "String"),
            @ApiImplicitParam(name = "cardNumber", value = "证件号", dataType = "String"),
            @ApiImplicitParam(name = "cardIndate", value = "证件过期时间", dataType = "Timestamp"),
            @ApiImplicitParam(name = "cardType", value = "证件类型", dataType = "String"),
    })
    @PostMapping("user/addTraveler")
    public Result changeState(String travelerName, String travelerType, String travelerTel,
                              String cardNumber, Timestamp cardIndate, String cardType){
        return Result.success("添加成功");
    }


    //----------------------------------------------------------------------------------------------
    @ApiOperation(value ="查看产品")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "key", value = "关键字", dataType = "String"),
    })
    @PostMapping("user/selectProduct")
    public Result auditArchitect(String key){
        List<Product> list=new ArrayList<>();
        return Result.success(list);
    }

    @ApiOperation(value ="下单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderPrice", value = "订单价格", dataType = "double"),
            @ApiImplicitParam(name = "orderType", value = "订单类型", dataType = "String"),
            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "int"),
            @ApiImplicitParam(name = "travelerId", value = "出行人id", dataType = "int"),
            @ApiImplicitParam(name = "tourId", value = "旅行团id", dataType = "int"),
            @ApiImplicitParam(name = "orderTime", value = "下单时间", dataType = "Timestamp"),
    })
    @PostMapping("user/makeOrder")
    public Result checkMaterialArchitect(double orderPrice,String orderType,int userId,
                                         int travelerId,int tourId,Timestamp orderTime){
        return Result.success("下单成功");
    }

    @ApiOperation(value ="查看订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageIndex", value = "页码", dataType = "int"),
            @ApiImplicitParam(name = "pageNum", value = "每页展示多少条数据", dataType = "int")
    })
    @GetMapping("user/selectOrder")
    public Result changeStateArchitect(int PageIndex,int pageNum){
        List<Order> list=new ArrayList<>();
        return Result.success();
    }
    //上传第三方协议
    //上传信息生成id
    @ApiOperation(value = "取消订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "订单id", dataType = "int")
    })
    @GetMapping("user/cancelOrder")
    public Result uploadTripleAgreement(int id){


        return Result.success("取消订单成功");
    }


    @ApiOperation(value ="用户付款")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", value = "订单id", dataType = "int"),
    })
    @GetMapping("user/pay")
    public Result auditDataArchitect(int orderId){
        return Result.success("付款成功");

    }

    @ApiOperation(value ="申请退款")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", value = "订单id", dataType = "int")
    })
    @GetMapping("user/refund")
    public Result checkTripleAgreement(int orderId){

        return Result.success("退款成功");

    }
    //发布优惠券
    @ApiOperation(value ="用户评论")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commentContent", value = "评论内容", dataType = "String")
            @ApiImplicitParam(name = "productId", value = "产品id", dataType = "int")
            @ApiImplicitParam(name = "commentTime", value = "评论时间", dataType = "Timestamp")
            @ApiImplicitParam(name = "commentImg", value = "评论图片", dataType = "MultipartFile")
    })
    @PostMapping("user/comment")
    public Result createCoupons(String commentContent, int productId,
                                Timestamp commentTime, MultipartFile commentImg){

        return Result.success("评论成功");
    }

    //投诉处理
    //投诉
    @ApiOperation(value = "用户投诉")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tourId", value = "团id", dataType = "int"),
            @ApiImplicitParam(name = "complaintsContent", value = "投诉内容", dataType = "String")
            @ApiImplicitParam(name = "complaintsTime", value = "投诉时间", dataType = "Timestamp")


    })
    @PostMapping("user/complaints")
    public Result checkComplain(int tourId,String complaintsContent,Timestamp complaintsTime){
        return Result.success("投诉成功");
    }

}
